<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 500px;
            height: 200px;
            border: 1px solid black;
            text-align: center;
            line-height: 50px;
            padding-top: 30px;
            margin: 150px auto;
            border-radius: 10px;
        }

        input {
            width: 250px;
            height: 30px;
            border-radius: 6px;
            outline: none;
        }

        .btn {
            width: 250px;
            height: 30px;
            /* margin-top: 20px; */
            outline: none;
            color: white;
            background-color: #4169E1;
        }
        span{
            display: block;
            font-size: 30px;
           line-height: 250px;
           text-align: center;
           width: 150px;
           height:50px;
           margin: auto;
        }
        a{
            text-decoration: none;
            color: black;
        }

    </style>
</head>

<body>
    <span>登陆页</span>
    <div class="box">
        <input type="text" class="top" placeholder="手机号/用户名/邮箱"> <br>
        <input type="password" placeholder="密码" class="mm"><br>
        <input type="button" class="btn" value="登陆"><br>
        <a href="file:///D:/wenjian/js%E7%BB%83%E4%B9%A03/%E5%86%85%E5%AE%B92/%E4%BD%9C%E4%B8%9A2.html">点击注册</a>
    </div>
</body>

</html>
<script src="./04-ajax.js"></script>
<script>
    var inputs = document.querySelectorAll('.box input')
    inputs[2].onclick = function () {
        if (inputs[0].value && inputs[1].value) {
            ///^1[3-9]\d{9}$/.test(inputs[0].value) &&
            if ( /^\d{4}$/.test(inputs[1].value)) {
                ajax('get', 'https://yantianfeng.com/api/login', { username: inputs[0].value, password: inputs[1].value }).then( (data) =>{
                    if( data.status == 200 ){
                            alert('登陆成功');
                        }else{
                            alert('登陆失败!');
                        }
                })
             }else{
                alert('你输错了，从新来')
            }
        } else {
            alert('哎哎哎，别空着呀')

        }
    }










</script>